;===================================================================================================
;	File: CWI Object CMD Line Interface
;
;	Used to implement the features of the CWI Class externally 
;	through CMD Line Parameters. This program will do nothing if run
;	stand-alone without receiving parameters.
;
; 													CMD LINE PARAMETERS	
;=========================================================================
;	CMD Line Switches:
;		List of accepted parameters and their functions. 
;
;		*Note: Items in {braces} are required, while items in [brackets] are optional.*
;
;		get_REFnum  <Object Number> - Copies the matching REF number to clipboard.
;				Object Number can be REF num or SAP num.
;		get_SAPnum <REF Number> - Copies the matching SAP number to clipboard.
;		URL <Object Num> [CWI view] - Opens the objects CWI page in the given view
;				(if given); Default view is Modify/VIew. See
;				below for list of acceptable inputs for [CWI View]
;
;		CWI View Options:
;					
;					n | nav | navigate 	-	Navigate view
;					sig | promote		-	View Signitures (promote)
;					wu | where used		-	Where Used
;					m | mod | modify	-	Modify RTA
;					p | print			-	Print layout
;					<If left blank>		- 	Modify/View
;___________________________________________________________________________________________________
;---------------------------------------------------------------------------------------------------
 #SingleInstance, Force
 #NoEnv
 SetWorkingDir, %a_scriptdir%
;---------------------------------------------------------------------------------------------------
;***************************************************************************************************







;===================================================
;						Handle Parameters
;===================================================
if (%0% > 0){
	loop %0%
		p%a_index% := % %a_index%
	
	ocwi := new cwi()	;New CWI class instance
	
	; Get REF / SAP / ID nums to clipboard
	;===================================
	if ((p1 = "get_sapnum" || p1="get_REFnum" || p1 = "get_ID") && p2){
		Clipboard = something		
		Clipboard := p1 = "get_sapnum" ? ocwi.get_sapnum(p2)
							  : p1 = "get_refnum" ? ocwi.get_refnum(p2)
							  :p1 = "get_ID" ? ocwi.get_id(p2)
							  : ""
		if clipboard		;Found it
			;~ tooltip, % (p1 = "get_sapNum" ? "SAP Num" : "REF Num") "Found. Copied to CB."
		sleep 900
		ExitApp
	}
	; OPEN objects page in CWIedit
	;===========================
	else if(p1="url" && p2){
		cwiUrl := ocwi.url(p2, p3)
		if cwiUrl
			run, iexplore.exe %cwiUrl%
		sleep, 300
		ExitApp
	}
	; ADD / REPLACE SAP num or ID entry
	;==================================
	else if((p1="add_SAP" || p1="add_ID") && p2 && p3){	
		err := p1 = "add_sap" ? ocwi.add_sap(p2, p3)
						: p1 = "add_id" ? ocwi.add_id(p2,p3)
		ExitApp
	}
	; DELETE SAP / ID entry
	;========================
	else if((p1="del_SAP" || p1="del_ID") && p2 && p3){
		err := p1 = "del_sap" ? ocwi.del_sap(p2, p3)
				: p1 = "del_id" ? ocwi.del_id(p2,p3)
		ExitApp
	}
	; Get some random vars to clipboard
	;=================================
	else{
		Clipboard := p1 = "inFIle" ? ocwi.infile(p2,P3)
					: P1 = "findPart" ? ocwi.find_part(p2)
					: p1 = "allIDs" ? ocwi.allIDs
					: p1 = "allSAPnums" ? ocwi.allsapnums
					: ""
	ExitApp
	}
	ExitApp
}


;______________________________________________________________
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
;				I N C L U D E
;
#Include %a_scriptdir%\oCWI.ahk
;______________________________________________________________
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

